// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Jieguo from './jieguo/jieguo.vue'
import router from './router/jieguo.js'

import axios from 'axios';
import qs from 'qs';
import Toast from './components/alert/alert.js';
import './components/alert/alert.css';
import {config,formatXml} from "./assets/js/confin.js";

axios.defaults.timeout = 1000;                        //响应时间
//axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';           //配置请求头
//axios.defaults.baseURL = 'http://192.168.1.61/newshengji';   //配置接口地址
//添加一个响应拦截器
axios.interceptors.request.use((config) => {
	//在发送请求之前做某件事
	// 判断是否登录
	let cur_id = sessionStorage.getItem("cur_id"),
	sign = sessionStorage.getItem("sign");
  	if (!cur_id||!sign) {
      sessionStorage.clear();
  		window.location.href = "index.html";
    };
    if(config.method  === 'post'){
        config.data = qs.stringify(config.data);
    }
    return config;
},(error) =>{
     _.toast("错误的传参", 'fail');
    return Promise.reject(error);
});




Vue.config.productionTip = false
Vue.prototype.$http= axios

/* eslint-disable no-new */
new Vue({
  el: '#jieguo',
  router,
  components: { Jieguo },
  template: '<Jieguo/>'
})
